<?php

use yii\helpers\Html;
use common\logic\OrderStatus;
use common\logic\SupplyStatus;
use common\logic\PaymentStatus;
use common\logic\AccountStatus;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model backend\models\Order */

$this->title = '更新订单';
$this->params['breadcrumbs'][] = [
    'label' => 'Orders',
    'url' => ['index']
];
$this->params['breadcrumbs'][] = [
    'label' => $model->id,
    'url' => [
        'view',
        'id' => $model->id
    ]
];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="order-update">

	<p>
        <?=Html::a('确认订单', [
            'platform-confirm',
            'id' => $model->id
        ], [
            'class' => $model->order_status == OrderStatus::PAID && $model->supply_status == SupplyStatus::UNSET && $model->payment_status == PaymentStatus::PAID && $model->account_status == AccountStatus::UNSET ? 'btn btn-primary' : 'btn btn-primary disabled',
            'data' => [
                'confirm' => '确认客户英文名为：' . $model->first_name . ' ' . $model->last_name . '(否则在当前页修改)，确定订单并向booker下单吗？',
                'method' => 'post',
            ],
        ]);?>
        <?=Html::a('供应商确认', [
            'supply-confirm',
            'id' => $model->id
        ], [
            'class' => $model->order_status == OrderStatus::PAID && $model->supply_status == SupplyStatus::ORDER && $model->payment_status == PaymentStatus::PAID && $model->account_status == AccountStatus::UNSET ? 'btn btn-primary' : 'btn btn-primary disabled',
            'data' => [
                'confirm' => '确认已收到booker邮件, 更新订单为供应商为确认状态吗？',
                'method' => 'post',
            ],
        ]);?>

        <?=Html::a('更新为向供应商汇款', [
            'remitting',
            'id' => $model->id
        ], [
            'class' => $model->order_status == OrderStatus::CONFIRMED && $model->supply_status == SupplyStatus::CONFIRMED && $model->payment_status == PaymentStatus::PAID && $model->account_status == AccountStatus::TO_REMIT ? 'btn btn-primary' : 'btn btn-primary disabled',
            'data' => [
                'confirm' => '准备向供应商汇款, 更新订单为供应商汇款状态吗？',
                'method' => 'post',
            ],
        ]);?>

        <?=Html::a('更新为供应商已收汇', [
            'remitted',
            'id' => $model->id
        ], [
            'class' => $model->order_status == OrderStatus::CONFIRMED && $model->supply_status == SupplyStatus::CONFIRMED && $model->payment_status == PaymentStatus::PAID && $model->account_status == AccountStatus::REMITTING ? 'btn btn-primary' : 'btn btn-primary disabled',
            'data' => [
                'confirm' => '已得到供应商收汇确认, 更新订单为供应商已收汇状态吗？',
                'method' => 'post',
            ],
        ]);?>


        <?=Html::a('取消订单并退款', [
            'refund',
            'id' => $model->id
        ], [
            'class' => $model->order_status == OrderStatus::PAID && $model->supply_status == SupplyStatus::UNSET && $model->payment_status == PaymentStatus::PAID && $model->account_status == AccountStatus::UNSET || $model->order_status == OrderStatus::PAID && $model->supply_status == SupplyStatus::ORDER && $model->payment_status == PaymentStatus::PAID && $model->account_status == AccountStatus::UNSET || $model->order_status == OrderStatus::CONFIRMED && $model->supply_status == SupplyStatus::CONFIRMED && $model->payment_status == PaymentStatus::PAID && $model->account_status == AccountStatus::TO_REMIT ? 'btn btn-primary' : 'btn btn-primary disabled',
            'data' => [
                'confirm' => '确认退款吗？',
                'method' => 'post',
            ],
        ]);?>
	</p>
    <?=$this->render('_form', [
        'model' => $model,
		'flow'=>$flow,
    ])?>

</div>
